﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace GeekShop
{
    public class MenuParent : MenuGroup
    {
        #region Fields
        private ToolStrip stripItem;
        private ToolStripMenuItem contextItem;
        #endregion

        #region Properties
        public ToolStrip StripItem
        {
            get { return stripItem; }
            set { stripItem = value; }
        }
        public ToolStripMenuItem ContextItem
        {
            get { return contextItem; }
            set { contextItem = value; }
        }
        #endregion

        #region Virtual Properties
        public new string Text
        {
            get { return base.Text; }
            set
            {
                base.Text = value;
                this.stripItem.Text = value;
                this.contextItem.Text = value;
            }
        }
        public new Image Image { get { return null; } }
        public new EventHandler OnClick
        {
            set
            {
                this.MenuItem.Click += value;
            }
        }
        public new bool ShowAsToolBar
        {
            get { return base.ShowAsToolBar; }
            set
            {
                base.ShowAsToolBar = value;
                this.stripItem.Visible = value;
                this.contextItem.Checked = value;
            }
        }
        #endregion

        #region Constructors
        public MenuParent()
        {
            this.MenuItem = new ToolStripMenuItem() { Visible = true };
            this.ToolItem = new ToolStripSplitButton() { Visible = true };
            this.stripItem = new ToolStrip() { Visible = true };
            this.contextItem = new ToolStripMenuItem() { Visible = true };
            this.contextItem.Checked = true;
            this.contextItem.Click += new EventHandler(contextItem_Click);
        }
        #endregion

        #region Public Methods
        public new void Add(MenuItem menuItem)
        {
            base.Add(menuItem);
            ((ToolStrip)this.stripItem).Items.Add(menuItem.ToolItem);
        }
        #endregion

        #region Event Methods
        void contextItem_Click(object sender, EventArgs e)
        {
            this.ShowAsToolBar = !this.ShowAsToolBar;
        }
        #endregion
    }
}
